package com.ruoyi.project.income.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.income.domain.BinsMerchantRecode;
import com.ruoyi.project.income.service.IBinsMerchantRecodeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 商户体现记录Controller
 * 
 * @author administrator
 * @date 2025-04-03
 */
@RestController
@RequestMapping("/income/recode")
public class BinsMerchantRecodeController extends BaseController
{
    @Autowired
    private IBinsMerchantRecodeService binsMerchantRecodeService;

    /**
     * 查询商户体现记录列表
     */
    @PreAuthorize("@ss.hasPermi('income:recode:list')")
    @GetMapping("/list")
    public TableDataInfo list(BinsMerchantRecode binsMerchantRecode)
    {
        startPage();
        if (null==binsMerchantRecode.getMerchantDeptId()) {
            binsMerchantRecode.setMerchantDeptId(getCommonDeptId());
        }
        List<BinsMerchantRecode> list = binsMerchantRecodeService.selectBinsMerchantRecodeList(binsMerchantRecode);
        return getDataTable(list);
    }

    /**
     * 导出商户体现记录列表
     */
    @PreAuthorize("@ss.hasPermi('income:recode:export')")
    @Log(title = "商户体现记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BinsMerchantRecode binsMerchantRecode)
    {
        List<BinsMerchantRecode> list = binsMerchantRecodeService.selectBinsMerchantRecodeList(binsMerchantRecode);
        ExcelUtil<BinsMerchantRecode> util = new ExcelUtil<BinsMerchantRecode>(BinsMerchantRecode.class);
        util.exportExcel(response, list, "商户体现记录数据");
    }

    /**
     * 获取商户体现记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('income:recode:query')")
    @GetMapping(value = "/{merchantDeptId}")
    public AjaxResult getInfo(@PathVariable("merchantDeptId") Long merchantDeptId)
    {
        return success(binsMerchantRecodeService.selectBinsMerchantRecodeByMerchantDeptId(merchantDeptId));
    }

    /**
     * 新增商户体现记录
     */
    @PreAuthorize("@ss.hasPermi('income:recode:add')")
    @Log(title = "商户体现记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BinsMerchantRecode binsMerchantRecode)
    {
        return toAjax(binsMerchantRecodeService.insertBinsMerchantRecode(binsMerchantRecode));
    }

    /**
     * 修改商户体现记录
     */
    @PreAuthorize("@ss.hasPermi('income:recode:edit')")
    @Log(title = "商户体现记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BinsMerchantRecode binsMerchantRecode)
    {
        return toAjax(binsMerchantRecodeService.updateBinsMerchantRecode(binsMerchantRecode));
    }

    /**
     * 删除商户体现记录
     */
    @PreAuthorize("@ss.hasPermi('income:recode:remove')")
    @Log(title = "商户体现记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{merchantDeptIds}")
    public AjaxResult remove(@PathVariable Long[] merchantDeptIds)
    {
        return toAjax(binsMerchantRecodeService.deleteBinsMerchantRecodeByMerchantDeptIds(merchantDeptIds));
    }
}
